<%@page import="dal.project.Project"%>
<%@page import="dal.project.ProjectUtil"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>List Of Projects</title>
<link rel="stylesheet" href="CssFiles/MyCssStyle.css" >


</head>
<body>


	<%
	
		response.setHeader("Cache-control", "no-cache, no-store");
		response.setHeader("Pragma", "no-cache");
		response.setHeader("Expires", "-1");
		
		response.setHeader("Access-Control-Allow-Origins", "*");
		response.setHeader("Access-Control-Allow-Methods", "POST");
		response.setHeader("Access-Control-Allow-Headers", "Content-type");
		response.setHeader("Access-Control-Max-Age", "86400");
		
			
		int val=Integer.parseInt(request.getParameter("isModify"));
		
		boolean isModify=false;
		if(val==0){
			isModify=false;
		}else if(val==1){
			isModify=true;
		}
	
	
		
		System.out.println(isModify);
		ArrayList<Object> al=new ProjectUtil().get();
		
		if(al.size()>0){
		
	%>
	
			<div>
				<fieldset>
					<legend>All Project Details</legend>
					<table style="border-collapse: collapse; " border="1">
						<tr>
							<th>Title</th>
							<th>Owner</th>
							<th>Location</th>
							<th>Date Started</th>
							<%
							if(isModify){
							%>
								<th></th>
							<%
							}
							 %>	
						</tr>
						<%
						for(Object obj:al){
							Project project=(Project)obj; 
						%>
							<tr>
								<td><%=project.getTitle() %></td>
								<td><%=project.getOwner() %></td>
								<td><%=project.getLocation() %></td>
								<td><%=project.getDate() %></td>
								<%
								if(isModify){
								%>
									<td><a href="ProjectModify.jsp?projId=<%=project.getProjectId() %>">Modify</a></td>
								<%
								}
								 %>	
							</tr>
						<%
						}
						%>					
					</table>
				</fieldset>
			</div>	
	<%		
		}else{
	%>
			<div>
				<fieldset>
					<b><font style="color: red;" >Sorry ! No records found</font> </b>	
				</fieldset>
			</div>
	<%		
		}
		
	 %>

</body>
</html>